{% extends 'default/base.html' %}
{% block content %}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>用户列表 | Users.</h2>
    </div>
    <div class="col-lg-2">
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="ibox float-e-margins">
            {% include "listOrAdd.html" %}
            <div class="ibox-title">
                <h5> 用户列表 </h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user"></ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>

            <div class="ibox-content">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th class="text-center">用户名</th>
                            <th class="text-center">名字</th>
                            <th class="text-center">邮箱</th>
                            <th class="text-center">部门</th>
                            <th class="text-center">状态</th>
                            <th class="text-center">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for i in users %}
                            <tr>
                                <td class="text-center">{{ i.username }}</td>
                                <td class="text-center">{{ i.first_name }}</td>
                                <td class="text-center">{{ i.email }}</td>
                                <td class="text-center">{{i.department}}</td>
                                <td class="text-center">
                                    {% if i.is_active  and i.is_staff and i.availabity %}
                                        <i class="fa fa-check-circle-o" style="color:#279048">正常</i>
                                    {% elif not i.availabity %}
                                            <i class="fa fa-ban" style="color:red">未激活</i>
                                    {% else %}
                                        <i class="fa fa-ban">禁用</i>
                                    {% endif %}</td>
                                </td>
                                <td class="text-center">
                                    <div class="btn-group" data-toggle="buttons">
                                      <a href="/accounts/auth/?id={{ i.id }}&m=myUser" class="btn btn-xs btn-info select_node"  >权限管理</a>
                                      <a href="/accounts/userEdit/?id={{ i.id }}" class="btn btn-xs btn-success " data-toggle="modal">修改</a>
                                    {% if not i.is_staff %}
                                        <a href="/accounts/userStatus/?id={{ i.id }}" class="btn btn-success btn-xs status" data-toggle="modal">恢复</a>
                                    {% else %}
                                         <a href="/accounts/userStatus/?id={{ i.id }}" class="btn btn-xs btn-warning status" data-toggle="modal">禁用</a>
                                        {% endif %}
                                      <a href="/accounts/userDel/?id={{ i.id }}" class="btn btn-xs btn-danger" data-toggle="modal">删除</a>
                                    </div>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $('.select_node').on('click', function (event) {
        var height = $(window).height(), index = $.layer({
            type: 2,
            shade: [0.5, '#000', true],
            shadeClose: true,
            maxmin: true,
            fix: true,
            moveOut: true,
            shift: 'top',
            border: [10, 0.3, '#000'],
            title: "权限分配",
            area: ['800px', (height - 50) + 'px'],
            //area : ['80%', (height - 50)+'px'],
            iframe: {src: $(this).attr('href')}
        });
        event.preventDefault();
    });
});
</script>
{% endblock content %}